import request from '@/utils/request'

export const UserRegisterService = (registerData) => {

    const params = new URLSearchParams()
    for (const key in registerData) {
        params.append(key, registerData[key])
    }

    return request.post('/user/register',params)
}

export const UserLoginService = (loginData) => {
    const params = new URLSearchParams()
    for (const key in loginData) {
        params.append(key, loginData[key])
    }

    return request.post('/user/login',params)
}

//获取用户详细信息

export const UserInfoService = () => {
    return request.get('/user/userinfo')
}

export const updateUserInfoService = (userInfo) => {
    return request.put('/user/update', userInfo)
}

export const updateAvterService = (avatar) => {
    const params = new URLSearchParams()
    params.append('avterUrl', avatar)

    // return request.post('/user/update/avatar', params)
    return request.patch("/user/updateAvter", params)
}